package cn.cau.epidemicsurveysystem.dao;

import cn.cau.epidemicsurveysystem.bean.EpidMissionRecordBean;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface EpidMissionRecordRepository extends JpaRepository<EpidMissionRecordBean,Integer> {
    @Override
    List<EpidMissionRecordBean> findAll(Sort sort);
    EpidMissionRecordBean findEpidMissionRecordBeanByMissionId(int missionId);

    @Override
    <S extends EpidMissionRecordBean> S save(S entity);
    List<EpidMissionRecordBean> findEpidMissionRecordBeansByAssigneeIdEquals(int staffId);
    List<EpidMissionRecordBean> findEpidMissionRecordBeansByRequestHospitalOrderByRequestTime(String hospital);
    List<EpidMissionRecordBean> findEpidMissionRecordBeansBySecondAssigneeIdEquals(int secondAssigneeId);

    @Query(value = "select * from epidMissionRecord where diseaseId = ?1 and missionState = 4", nativeQuery = true)
    List<EpidMissionRecordBean> findConfirmedCasesByDiseaseId(int diseaseId);

    @Query(value = "select * from epidMissionRecord where diseaseId = ?1 and missionState != 4 and missionState !=3 and missionState!=0 and missionState!=1", nativeQuery = true)
    List<EpidMissionRecordBean> findSuspectedCasesByDiseaseId(int diseaseId);
}
